package com.titar.robot.ui.control;

import android.graphics.Rect;
import android.view.View;

import com.titar.robot.R;
import com.titar.robot.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;


public class ActionFragment extends BaseFragment {

    private RecyclerView control_action_fragment_ry;
    private ControlAdapter adapter;
    private List<String> lists = new ArrayList<>();


    @Override
    public int getViewId() {
        return R.layout.layout_control_fragment_action;
    }

    @Override
    public void init() {
        for (int j = 0; j < 10; j++) {
            lists.add("动作" + j);
        }
        control_action_fragment_ry = getView().findViewById(R.id.control_action_fragment_ry);
        control_action_fragment_ry.setLayoutManager(new GridLayoutManager(getContext(), 4));
        control_action_fragment_ry.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
                outRect.top = 50;
                outRect.left = 0;
                outRect.right = 0;
                outRect.bottom = 50;
            }
        });
        adapter = new ControlAdapter(getContext(), lists);
        control_action_fragment_ry.setAdapter(adapter);
    }
}
